//
//  MoneyDetailsTableViewCell.m
//  Findif
//
//  Created by Mac on 2018/11/1.
//  Copyright © 2018年 Cicel Chen. All rights reserved.
//

#import "MoneyDetailsTableViewCell.h"


@interface MoneyDetailsTableViewCell ()

//@property (nonatomic, weak)UIImageView * iconImageView;
@property (nonatomic, weak)UILabel * nameLabel;
@property (nonatomic, weak)UILabel * timeLabel;
@property (nonatomic, weak)UILabel * moneyLabel;
@property (nonatomic, weak)UIView * lineView;

@end

@implementation MoneyDetailsTableViewCell


- (void)setModel:(MoneyDetailsModel *)model{
    
    _model = model;

    self.nameLabel.text = [NSString stringWithFormat:@"%@",model.cost_instructions];
    self.timeLabel.text = [NSString stringWithFormat:@"%@",model.inputtime];
    self.moneyLabel.text = [NSString stringWithFormat:@"￥%@",model.cost];
}


- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    
    if ([super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        
        [self setupUI];
    }
    
    return self;
}

- (void)setupUI{
    
    self.selectionStyle = UITableViewCellSelectionStyleNone;
    self.backgroundColor = [UIColor whiteColor];
    
//    UIImageView * iconImageView = [UIImageView new];
//
//    iconImageView.backgroundColor = [UIColor lightGrayColor];
//    iconImageView.layer.cornerRadius = 22.5 * SCREENH6;
//    iconImageView.layer.masksToBounds = YES;
//
//    self.iconImageView = iconImageView;
//
//    [self.contentView addSubview:self.iconImageView];
    
    
    UILabel * nameLabel = [UILabel new];
    
    nameLabel.text = @"人民健身房";
    nameLabel.textColor = ZRBlackColor;
    nameLabel.font = [UIFont systemFontOfSize:15 * SCREENH6];
    
    self.nameLabel = nameLabel;
    
    [self.contentView addSubview:self.nameLabel];
    
    
    UILabel * timeLabel = [UILabel new];
    
    timeLabel.text = @"2018-10-24 22:24:16";
    timeLabel.textColor = [UIColor lightGrayColor];
    timeLabel.font = [UIFont systemFontOfSize:15 * SCREENH6];
    
    self.timeLabel = timeLabel;
    
    [self.contentView addSubview:self.timeLabel];
    
    
    UILabel * moneyLabel = [UILabel new];
    
    moneyLabel.text = @"-￥12";
    moneyLabel.textColor = [UIColor lightGrayColor];
    moneyLabel.font = [UIFont systemFontOfSize:15 * SCREENH6];
    
    self.moneyLabel = moneyLabel;
    
    [self.contentView addSubview:self.moneyLabel];
    
    
    UIView * lineView = [UIView new];
    
    lineView.backgroundColor = ColorWithRGB(0xF5F5F5);
    
    self.lineView = lineView;
    
    [self.contentView addSubview:self.lineView];
}


- (void)layoutSubviews{
    
//    [self.iconImageView mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.leading.mas_equalTo(self.contentView).offset(15 * SCREENH6);
//        make.centerY.mas_equalTo(self.contentView);
//        make.width.height.mas_equalTo(45 * SCREENH6);
//    }];
    
    [self.nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.leading.mas_equalTo(self.contentView).offset(15 * SCREENH6);
        make.width.mas_equalTo(270 * SCREENH6);
        make.top.mas_equalTo(self.contentView).offset(10 * SCREENH6);
    }];
    
    [self.timeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(self.nameLabel.mas_bottom).offset(5 * SCREENH6);
        make.leading.mas_equalTo(self.nameLabel);
    }];
    
    [self.moneyLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.trailing.mas_equalTo(self.contentView).offset(-15 * SCREENH6);
        make.centerY.mas_equalTo(self.contentView);
    }];
    
    [self.lineView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.leading.mas_equalTo(self.nameLabel);
        make.trailing.mas_equalTo(self.moneyLabel);
        make.height.mas_equalTo(1 * SCREENH6);
        make.bottom.mas_equalTo(self.contentView);
    }];
}

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
